﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLDBHYT.DAO;
using QLDBHYT.VO;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace QLDBHYT.BUS
{
    class P1hBUS
    {
        private P1hDAO p1dDAO;
        public P1hBUS()
        {
            p1dDAO = new P1hDAO();
        }
        public P1hVO GetMathe(string mathe)
        {

            P1hVO p1dVO = new P1hVO();
            DataTable dataTable = new DataTable();
            dataTable = p1dDAO.SearhMathe(mathe);
            foreach (DataRow dr in dataTable.Rows)
            {
                p1dVO.Hoten = dr["ho_ten"].ToString();
                p1dVO.Gioitinh = Convert.ToInt16(dr["gioi_tinh"]);
                p1dVO.Namsinh = Convert.ToInt16(dr["nam_sinh"]);
                p1dVO.Diachi  = dr["dia_chi"].ToString();
                p1dVO.Tinhkcb = Convert.ToString(dr["tinh_kcb"]);
                p1dVO.Makcb = dr["ma_kcb"].ToString();
                p1dVO.Noikham  = dr["noi_kham"].ToString();
                p1dVO.Gttu = dr["gtri_tu"].ToString();
                p1dVO.Gtden = dr["gtri_den"].ToString();
                p1dVO.Benhvien = dr["noi_kham"].ToString();
              
            }
            return p1dVO;
        }


        public List<khoakhamVO> GetKhoaKham()
        {

            List<khoakhamVO> lstP1hVO = new List<khoakhamVO>();
            khoakhamVO P1hVO;
            DataTable dataTable = new DataTable();
            dataTable = p1dDAO.SearchKhoa();
            foreach (DataRow dr in dataTable.Rows)
            {
                P1hVO = new khoakhamVO();
                P1hVO.Makhoa = dr["Ma_khoa"].ToString();
                P1hVO.Tenkhoa = dr["Ten_khoa"].ToString();
                lstP1hVO.Add(P1hVO);
            }
            return lstP1hVO;
        }
        public List<ThuocVO> GetTenHieu(int thang,int nam)
        {

            List<ThuocVO> lstThuocVO = new List<ThuocVO>();
            ThuocVO thuocVO;
            DataTable dataTable = new DataTable();
            dataTable = p1dDAO.SearchTenHieu(thang,nam);
            foreach (DataRow dr in dataTable.Rows)
            {
                thuocVO = new ThuocVO();
                thuocVO.Sttnh  = dr["stt_nh"].ToString().Trim();
                thuocVO.Mahieu = dr["Ma_hieu"].ToString().Trim();
                thuocVO.Tenhieu = dr["ten_hieu"].ToString().Trim();
                thuocVO.Dvt = dr["dvt"].ToString();
                thuocVO.Gia  = Convert.ToDecimal(dr["gia"]);
                thuocVO.Soluong = Convert.ToInt32(dr["slcuoiky"]);
                thuocVO.Giabhxh = Convert.ToDecimal(dr["gia_bhxh"]);
                lstThuocVO.Add(thuocVO);
            }
            return lstThuocVO;
        }
    }
}
